package com.rattsoftware.server.serviceImpl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rattsoftware.server.admin.model.Staff;
import com.rattsoftware.server.admin.model.exceptions.RattsSecurityException;
import com.rattsoftware.server.admin.model.paging.PagingLoadConfig;
import com.rattsoftware.server.admin.model.paging.PagingLoadResult;
import com.rattsoftware.server.dao.StaffDAO;
import com.rattsoftware.server.service.StaffService;

@Service("staffService")
@Transactional
public class StaffServiceImpl implements StaffService{

	@Autowired
	private StaffDAO staffDAO;
	private Logger log = LoggerFactory.getLogger(StaffServiceImpl.class);
	
	@Override
	public void deleteStaff(Staff staff) throws RattsSecurityException {
		log.debug("Deleting Staff with names " + staff.getFirstName() + " " + staff.getLastName());
		staffDAO.deleteStaff(staff);
	}

	@Override
	public Staff getStaff(String firstName, String lastName)
			throws RattsSecurityException {
		return staffDAO.getStaff(firstName, lastName);
	}

	@Override
	public List<Staff> getStaffList() throws RattsSecurityException {
		return staffDAO.getStaff();
	}

	@Override
	public PagingLoadResult<Staff> getStaffList(PagingLoadConfig pagingLoadConfig) throws RattsSecurityException {
		return staffDAO.getStaffList(pagingLoadConfig);
	}

	@Override
	public void saveStaff(Staff staff) throws RattsSecurityException {
		staffDAO.saveStaff(staff);
	}

	@Override
	public void saveStaff(List<Staff> staffList) throws RattsSecurityException {
		for (Staff staff : staffList) {
			staffDAO.saveStaff(staff);
		}
	}

	@Override
	public PagingLoadResult<Staff> getStaffList(Integer deptId,
			PagingLoadConfig pagingLoadConfig) throws RattsSecurityException {
		return staffDAO.getStaffList(deptId, pagingLoadConfig);
	}
}
